include "stryker_curve.ms"
wallthickness = 1.1
totalLength = 50
totalWidth = 100
totalHeight = 40 --these numbers are used to create bounding box that object will be booleaned from
FilletSize = 1 --amount to fillet chamferbox

mountwidth = totalheight

mountExtraLength = 2
mountExtraHeight = 3
mountLength = totalLength + mountExtraLength
mountHeight = totalHeight + mountExtraHeight
mountYoffset = mountExtraLength* 0.5
mountYpos = -1*wallthickness - mountYoffset


baseHoleRadius = (3.2/2) --hole width is 3 mm using 4.5 for fudge factor
baseHoleWidth = baseHoleRadius*2
closerHoleDistance = 46.23 + baseHoleWidth
fartherHoleDistance = 68.74+ baseHoleWidth
frontToBackDistance = 32.84 + baseHoleWidth

firstHoleYoffset = 5.6 --distance from hole closest to back of mount to back of mount

deleteCurveWidth = ((totalWidth - mountWidth - (wallthickness*2))/2)

--motor mount specifics
motormountHeight = 26

motorHoleRadius = 1.3 --actual = 1 adding fudge
baseCylinderRadius = (25.06/2)
holeToCylinder = 1.32
centerHoleRadius = 5
holeOffset = baseCylinderRadius - holeToCylinder - motorHoleRadius


--this could have easily been done with a chamferbox, live and learn
mountSub = ChamferBox Length_Segments:1 Width_Segments:1 Height_Segments:1 Fillet_Segments:3 length:mountLength width:mountwidth height:(mountHeight*2) Fillet:FilletSize smooth:1 mapcoords:1 pos:[0,mountYpos,wallthickness] isSelected:on
rightSide = ChamferBox Length_Segments:1 Width_Segments:1 Height_Segments:1 Fillet_Segments:3 length:(mountLength*2) width:mountwidth height:(mountHeight*2) Fillet:FilletSize smooth:1 mapcoords:1 pos:[(mountWidth + wallthickness),mountYpos,wallthickness] isSelected:on
leftSide = ChamferBox Length_Segments:1 Width_Segments:1 Height_Segments:1 Fillet_Segments:3 length:(mountLength*2) width:mountwidth height:(mountHeight*2) Fillet:FilletSize smooth:1 mapcoords:1 pos:[(0 - mountWidth - wallthickness),mountYpos,wallthickness] isSelected:on
--TestBase = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:totalLength width:totalWidth height:wallThickness mapcoords:on pos:[0,0,0] isSelected:on
base = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:totalLength width:totalWidth height:totalHeight mapcoords:on pos:[0,0,0] isSelected:on


--wallthickness*3 is just a fudge factor to get rid of stl errors

deleteCurve = Rectangle length:mountwidth width:totalLength cornerRadius:0 transform:(matrix3 [0,1,0] [0,0,1] [1,0,0] [(-1*totalLength ),(-1*wallthickness),(mountwidth/2) + wallthickness*3]) isSelected:on
macros.run "Modifier Stack" "Convert_to_Spline"
subobjectLevel = 1
modPanel.setCurrentObject $.baseObject

deleteKnot deleteCurve 1 4
updateShape deleteCurve
modPanel.addModToSelection (Extrude ()) ui:on
$.modifiers[#Extrude].amount = (totalLength*2)
	
hole1 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*3) radius:baseHoleRadius mapcoords:on pos:[(-0.5*closerHoleDistance),((totalLength/2) - baseHoleWidth - firstHoleYoffset),(-0.5*wallthickness*3)] isSelected:on
hole2 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*3) radius:baseHoleRadius mapcoords:on pos:[(0.5*closerHoleDistance),((totalLength/2) - baseHoleWidth - firstHoleYoffset),(-0.5*wallthickness*3)] isSelected:on
hole3 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*3) radius:baseHoleRadius mapcoords:on pos:[(0.5*fartherHoleDistance),((totalLength/2) - baseHoleWidth - firstHoleYoffset - frontToBackDistance),(-0.5*wallthickness*3)] isSelected:on
hole4 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*3) radius:baseHoleRadius mapcoords:on pos:[(-0.5*fartherHoleDistance),((totalLength/2) - baseHoleWidth - firstHoleYoffset - frontToBackDistance),(-0.5*wallthickness*3)] isSelected:on

Cylinderradius = distance [0,0,0] hole4.pos
Cylinderradius += 3*baseHoleRadius

boundCylinder = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(totalHeight*2) radius:Cylinderradius mapcoords:on pos:[0,0,(-0.5*totalHeight)] isSelected:on





--make use of ProBoolean instead, does a nicer job



--ADD motor mount


--base = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:wallthickness radius:baseCylinderRadius mapcoords:on pos:[0,0,0] isSelected:on
centerHole = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*4) radius:centerHoleRadius mapcoords:on pos:[0,0,(-0.5*wallthickness)] isSelected:on
centerOuterHole = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*4) radius:motorHoleRadius mapcoords:on pos:[0,(-1*holeOffset),(-0.5*wallthickness)] isSelected:on
centerOuterHole.pivot = [0,0,0]
centerOuterHole.pivot = centerOuterHole.center

motorhole2 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*4) radius:motorHoleRadius mapcoords:on pos:[0,(-1*holeOffset),(-0.5*wallthickness)] isSelected:on
motorhole2.pivot = [0,0,0]
motorhole2.rotation.z_rotation = 140
motorhole2.pivot = motorhole2.center

motorhole3 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*4) radius:motorHoleRadius mapcoords:on pos:[0,(-1*holeOffset),(-0.5*wallthickness)] isSelected:on
motorhole3.pivot = [0,0,0]
motorhole3.rotation.z_rotation = 220
motorhole3.pivot = motorhole3.center

select #(centerHole, centerOuterHole, motorhole2, motorhole3)
motorGroup = group selection name: "tempGroup"
select motorGroup

rotate motorGroup (angleaxis 90 [1,0,0])
motorGroup.pos = [0,totalLength/2,motormountheight]
ungroup
sideHoleRadius = ((totalLength - mountwidth - 2*wallthickness))
weightHole1 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*4) radius:(0.75*mountwidth/2) mapcoords:on pos:[0,0,(-0.5*wallthickness)] isSelected:on
weightHole2 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*4) radius:sideHoleRadius mapcoords:on pos:[(sideHoleRadius+mountwidth/2+wallthickness*3),0,(-0.5*wallthickness)] isSelected:on
weightHole3 = Cylinder smooth:on heightsegs:1 capsegs:1 sides:25 height:(wallthickness*4) radius:sideHoleRadius mapcoords:on pos:[-1*(sideHoleRadius+mountwidth/2+wallthickness*3),0,(-0.5*wallthickness)] isSelected:on

select base

 A = createStrykerCurve();
 B = createStrykerCurve();
 B.center.z = b.center.z + 1
ProBoolean.CreateBooleanObject B A 2 0 1; --2 mean Subtraction ,0 mean Reference, 1 mean Retain Original Material
addCurve = B

 subCurve = createStrykerCurve()

ProBoolean.CreateBooleanObject base mountSub 2 0 1
ProBoolean.CreateBooleanObject base leftSide 2 0 1
ProBoolean.CreateBooleanObject base rightSide 2 0 1
ProBoolean.CreateBooleanObject base deleteCurve 2 0 1
ProBoolean.CreateBooleanObject base subCurve 2 0 1
ProBoolean.CreateBooleanObject base addCurve 0 0 1

ProBoolean.CreateBooleanObject base hole1 2 0 1
ProBoolean.CreateBooleanObject base hole2 2 0 1
ProBoolean.CreateBooleanObject base hole3 2 0 1
ProBoolean.CreateBooleanObject base hole4 2 0 1
ProBoolean.CreateBooleanObject base centerHole 2 0 1
ProBoolean.CreateBooleanObject base centerOuterHole 2 0 1
ProBoolean.CreateBooleanObject base motorhole2 2 0 1
ProBoolean.CreateBooleanObject base motorhole3 2 0 1
ProBoolean.CreateBooleanObject base weightHole1 2 0 1
ProBoolean.CreateBooleanObject base weightHole2 2 0 1
ProBoolean.CreateBooleanObject base weightHole3 2 0 1
ProBoolean.CreateBooleanObject base boundCylinder 1 0 1